package com.xinggq.user.service;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import com.xinggq.common.utils.StartupInfoPrinter;
import lombok.extern.slf4j.Slf4j;

/**
 * 用户中心服务启动类
 *
 * @author xinggq
 * @since 2024-01-01
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableAsync
@MapperScan("com.xinggq.user.service.mapper")
@ComponentScan(basePackages = {
    "com.xinggq.user",
    "com.xinggq.common"
})
@Slf4j
public class UserCenterApplication {

    public static void main(String[] args) {
        var context = SpringApplication.run(UserCenterApplication.class, args);
        Environment env = context.getEnvironment();
        StartupInfoPrinter.printUserCenterStartupInfo(env);
        
        // 统一日志输出
        String serverPort = env.getProperty("server.port", "8080");
        String contextPath = env.getProperty("server.servlet.context-path", "");
        String profile = env.getProperty("spring.profiles.active", "default");
        String appName = env.getProperty("spring.application.name", "User Center Service");
        
        log.info("User Center '{}' started successfully at http://localhost:{}{}, profile={}", 
                appName, serverPort, contextPath, profile);
    }
}